package com.bwie.service.impl;

import com.bwie.common.domain.Goods;
import com.bwie.common.domain.GoodsScope;
import com.bwie.common.domain.GoodsType;
import com.bwie.common.domain.request.GoodsRequest;
import com.bwie.common.result.PageResult;
import com.bwie.mapper.GoodsMapper;
import com.bwie.service.GoodsService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @className: GoodsServiceImpl
 * @Description: TODO
 * @version: v1.８.0
 * @author: 刘茂锴
 * @date: 2025/10/13 13:36
 */
@Service
public class GoodsServiceImpl implements GoodsService {
    @Autowired
    private GoodsMapper goodsMapper;

    //商品列表
    @Override
    public PageResult<Goods> goodsList(GoodsRequest goodsRequest) {
        PageHelper.startPage(goodsRequest.getPageNum(), goodsRequest.getPageSize());
        List<Goods> list=goodsMapper.goodsList(goodsRequest);
        PageInfo<Goods> info = new PageInfo<>(list);
        return PageResult.toPageResult(info.getTotal(), info.getList());
    }

    //商品范围下拉框
    @Override
    public List<GoodsScope> goodsScopeList() {
        return goodsMapper.goodsScopeList();
    }

    //商品类型下拉框
    @Override
    public List<GoodsType> goodsTypeList() {
        return goodsMapper.goodsTypeList();
    }
}
